<template>
  <vxe-form
    :data="formData"
    :items="formItems"
    :rules="formRules"
    title-align="right"
    title-width="100"
    @submit="submitEvent">
  </vxe-form>
</template>

<script>
export default {
  name: 'LVxeFrom',
  props: {
    submitLoading: {
      type: Boolean,
      default: false
    },
    formData: {
      type: Object,
      default: null
    },
    formRules: {
      type: Object,
      default: null
    },
    formItems: {
      type: Array,
      default: null
    }
  },
  data () {
    return {

    }
  },
  methods: {
    submitEvent () {
      this.submitLoading = true
      setTimeout(() => {
        const $table = this.$refs.xTable
        this.submitLoading = false
        this.showEdit = false
        if (this.selectRow) {
          this.$XModal.message({ content: '保存成功', status: 'success' })
          Object.assign(this.selectRow, this.formData)
        } else {
          this.$XModal.message({ content: '新增成功', status: 'success' })
          $table.insert(this.formData)
        }
      }, 500)
    }
  }
}
</script>

<style scoped>

</style>
